package api

import (
	"github.com/gin-gonic/gin"
	"github.com/share309/gojwt"
	"zy5/api/handler"
	middleware "zy5/api/middlerware"
	"zy5/consts"
)

func LoadRoutes(r *gin.Engine) {
	r.Use(middleware.RunTime())
	r.Use(middleware.Cors())

	api := r.Group("/api")
	{
		user := api.Group("/user")
		{
			user.POST("/login", handler.Login)
			user.POST("/register", handler.Register)
		}
		shop := api.Group("/shop")
		{
			shop.Use(gojwt.JWTAuth(consts.JWT_KEY))
			shop.POST("/add", handler.Add)
			shop.POST("/update", handler.Update)
			shop.POST("/remove", handler.Remove)
			shop.GET("/list", handler.List)
			shop.GET("/page", handler.Page)
		}
		like := api.Group("/like")
		{
			like.Use(gojwt.JWTAuth(consts.JWT_KEY))
			like.POST("/add", handler.LikeAdd)
			like.POST("/remove", handler.LikeRemove)
			//like.GET("/search", handler.SearchList)
		}
		comment := api.Group("/comment")
		{
			comment.Use(gojwt.JWTAuth(consts.JWT_KEY))
			comment.POST("/remove", handler.CommentRemove)
			comment.GET("/list", handler.CommentList)
		}
	}
}
